import 'package:flutter/material.dart';
import 'package:luckiness/utils/general.dart';

class Evaluate extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return EvaluateState();
  }
}

class EvaluateState extends State<Evaluate> {

  FocusNode node = FocusNode();
  String eva = '';
  Color selectedColor = Color.fromRGBO(248, 236, 44, 1);
  Color defaultColor = Color.fromRGBO(192, 188, 188, 1);
  bool laughSelected = true;
  bool crySelected = false;
  @override
  void dispose() {
    // TODO: implement dispose
    // FocusScope.of(context).requestFocus(node);
    super.dispose();
  }

  void willPopScope(){
    FocusScope.of(context).requestFocus(node);
  }

  void submit() {
    willPopScope();
  }

  @override
  Widget build(BuildContext context) {
    double scale = widthScale(context);
    return Scaffold(
      appBar:AppBar(
        title:Text('评价'),
      ),
      body: SingleChildScrollView(
        child: Stack(
        children:[
          Container(
            color:Colors.green[100],
            height: screenHeight(context) - statusBarHeight(context) - 54,
            width: screenWidth(context),
          ),
          Container(
              height:300.0,
              width: screenWidth(context),
              decoration: BoxDecoration(
                borderRadius:BorderRadius.circular(30),
                border: Border.all(color:Colors.blue, width:1.0),
                color:Colors.brown,
              ),
              child:Column(
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  Padding(
                    padding: EdgeInsets.fromLTRB(0, 26 * scale, 0, 18 *scale),
                    child:Text('"满意"', style:TextStyle(fontSize:18, color:Colors.black87)),
                  ),
                  Row(
                    mainAxisAlignment:MainAxisAlignment.center,
                    children:[
                      Padding(
                        padding: EdgeInsets.symmetric(horizontal:0 * scale),
                        child:FlatButton(
                          onPressed: (){
                            if (!laughSelected) {
                              setState(() {
                                laughSelected = true;
                                crySelected = false;
                              });
                            }
                          }, 
                          child: Icon(Icons.highlight, size:40, color:laughSelected ? selectedColor : defaultColor),),
                      ),
                      Padding(
                        padding: EdgeInsets.symmetric(horizontal:0 * scale),
                        child:FlatButton(
                          onPressed: (){
                            if (!crySelected) {
                              setState(() {
                                crySelected = true;
                                laughSelected = false;                                
                              });
                            }
                          }, 
                          child: Icon(Icons.highlight, size:40, color:crySelected ? selectedColor : defaultColor),),
                      ),                
                    ]
                  ),
                Container(
                  padding:EdgeInsets.fromLTRB(15 * scale, 28 * scale, 15 * scale, 0),
                  child: SizedBox(
                    // height:125 * scale,
                    child: TextField(
                      maxLength: 200,
                      maxLines: 4,
                      onChanged: (str){
                        eva = str;
                      },
                      style:TextStyle(fontSize:15 * scale, color:Colors.black87),
                      decoration:InputDecoration(
                        hintText:'请输入评价内容（可不填）',
                        hintStyle:TextStyle(fontSize: 13 * scale),
                        border:InputBorder.none,
                        filled: true,
                        fillColor: Colors.red[100],
                        hoverColor: Colors.blue[100],
                        contentPadding: EdgeInsets.all(12.0 * scale),
                      )
                    )
                  ), 
                )
              ],
            ),
          ),
          Positioned(
            bottom: 0,
            height: 60 * scale,
            width: screenWidth(context),
            child: Container(
              color:Colors.white,
              padding:EdgeInsets.fromLTRB(15 * scale, 10 * scale, 15 * scale, 10 * scale),
              child:FlatButton(
                color: Color.fromRGBO(144, 192, 239, 1.0),
                onPressed: (){
                  submit();
                }, 
                child: Text('提交'),
              )
            ))
        ],
      ),

      ),
    );
  }
}